#!/sbin/sh
# Script for checking prerequisites for OpenSIPS-pgsql

BASE="OpenSIPS-base"
LIBPGSQL="libpq.so.5"
TMPLIST="/tmp/.opensipspgsql"

pkginfo | grep -i $BASE > /dev/null

if [ $? -eq 1 ]
then
        echo "OpenSIPS-pgsql depends on package OpenSIPS-base which is not installed";
        exit 1;
fi

find / -name $LIBPGSQL > $TMPLIST 2>&1
lines=`wc -l $TMPLIST`

if [ $lines = "0" ]
then
        echo "OpenSIPS-pgsql depends on PostgreSQL Client Libraries, which cannot be found on system";
        exit 1;
else
        exit 0;
fi
